package com.example.demo.controller;

import com.example.demo.entity.Book;
import com.example.demo.entity.BookVO;
import com.example.demo.entity.Shouye;
import com.example.demo.service.ShouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;

@RestController
@CrossOrigin
public class Shoucontroller {
    @Autowired
    ShouService shouService;

    @GetMapping("/shouye")
    public Map shouye(BookVO bookVO,Shouye shouye){
        Map map = new HashMap();
        BookVO bookVO1=new BookVO();

        ArrayList<Integer> list1 = new ArrayList<>();

        Integer j = shouService.jieyueshouye(bookVO1);
        Integer h = shouService.huanshushouye(bookVO1);
        Integer bookcount = shouService.countshouye(bookVO);
        Integer dianji = shouService.dianji(shouye);
        list1.add(j);
        list1.add(h);
        list1.add(bookcount);
        list1.add(dianji);


        map.put("code", 0);
        map.put("msg", "更新成功！");
        map.put("data",list1);
        return map;
    }

    @GetMapping("liucheng")
    public Map liucheng(BookVO bookVO){
        Map map = new HashMap();

        ArrayList<Integer> list2 = new ArrayList<>();

        Integer one = shouService.one(bookVO);
        Integer two = shouService.two(bookVO);
        Integer three = shouService.three(bookVO);
        Integer four = shouService.four(bookVO);
        Integer five = shouService.five(bookVO);
        Integer six = shouService.six(bookVO);
        list2.add(one);
        list2.add(two);
        list2.add(three);
        list2.add(four);
        list2.add(five);
        list2.add(six);

        map.put("code", 0);
        map.put("msg", "更新成功！");
        map.put("data",list2);
        return map;
    }
}
